

package cn.shengchao.controler.query;

import cn.shengchao.page.PageFactory;
import cn.shengchao.util.helper.LoginHelper;
import cn.shengchao.examstar.account.acl.ports.repositories.IAccountRepository;
import cn.shengchao.examstar.account.infrastructure.dao.vo.AccountList;
import cn.shengchao.examstar.account.infrastructure.dao.vo.PayoutsList;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@CrossOrigin("${project.cross-origin}")
@RequestMapping("/api/${project.version}/account/query")
public class AccountQueryController {

    @Autowired
    private IAccountRepository iAccountRepository;

    @GetMapping("accountLog")
    public List<AccountList> accountLists() {
        Long userId = LoginHelper.getUserId();
        return PageFactory.page(() -> iAccountRepository.accountLists(userId));
    }

    @GetMapping("payoutsLog")
    public List<PayoutsList> payoutsLog() {
        Long userId = LoginHelper.getUserId();
        return PageFactory.page(() -> iAccountRepository.payoutsLog(userId));
    }

}
